<?php 
session_start(); 
$cuid = $_SESSION['username'];
$messageid = $_POST['mesgrec'];
//$cuid='gip2103';
//$messageid='3';

//echo 'Message'.$messageid;

$conn = oci_connect("gaurav", "gaurav", "xe"); 

$query = "DELETE FROM Messages M WHERE M.MessageID = :MesgId";

  $conn = oci_connect("gaurav", "gaurav", "xe"); 
  $bindargs = array();
  array_push($bindargs, array('MESGID', $messageid, -1));

$r = db_execute_statement($conn, $query, $bindargs);
  //   $pointer = db_do_query($conn, $query, OCI_FETCHSTATEMENT_BY_ROW,$bindargs);
 //  $pointer = db_do_query($conn, $query, OCI_FETCHSTATEMENT_BY_ROW); 
 
 function db_execute_statement($conn, $statement, $bindvars = array())
{
  $stid = oci_parse($conn, $statement);
  if (!$stid) {
    db_error($conn, __FILE__, __LINE__);
  }
    // Bind parameters
  foreach ($bindvars as $b) {
    // create local variable with caller specified bind value 
    $$b[0] = $b[1];
    $r = oci_bind_by_name($stid, ":$b[0]", $$b[0], $b[2]);
    if (!$r) {
      db_error($stid, __FILE__, __LINE__);
    }
  }

  $r = oci_execute($stid);
  if (!$r) {
    db_error($stid, __FILE__, __LINE__);
  }
  return($r);
}
header('Location: /ViewMessagesProfessor.php');

?>